#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5;
int t,n,m,L,sV;
int d[MAXN];
int sv[MAXN];
int a[MAXN];
int p[MAXN];
double ddl[MAXN];
bool A,B,C;
int ans = 0;
int sea(int l,int r,int tf){//return after or cur
    if(l==r) return l;
    int mid = (l+r)>>1;
    if(p[mid] == tf){
        return mid;
    }
    if(p[mid]>tf){
        return sea(l,mid,tf);
    }
    return sea(mid+1,r,tf);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> t;
    for(int k =0;k<t;++k){
        cin  >> n >> m >> L>>sV;
        sV*=sV;
        A=true;
        B=true;
        C=true;
        for(int i =1;i<=n;i++){

            cin >>d[i]>>sv[i]>>a[i];
            A&=(a[i]==0);
            B&=(a[i]>0);
            C&=(a[i]<0);
            sv[i]*=sv[i];
        }
        for(int i =1;i<=m;i++){
            cin >>p[i];
        }
        sort(p+1,p+1+m);
        if(A){
            for(int i =1;i<=n;i++){
                if(d[i]<=p[m]&sv[i] > sV){
                    ans ++;
                }
                cout << ans << " ";
                cout << m-1;
            }
            return 0;
        }
        if(B){
            double ddl;
            for(int i =1;i<=n;i++){
                if(sv[i] > sV){
                    ddl = d[i];
                }else{
                    ddl = sV-sv[i];
                    ddl/= 2*a[i];
                    ddl+=d[i];
                }
                if(ddl<=p[m]){
                    ans ++;
                }
                cout << ans << " ";
                cout << m-1;
            }
            return 0;
        }
        if(C){
            double ddl;
            for(int i =1;i<=n;i++){
                if(sv[i] < sV){
                    ddl = L+1;
                }else{
                    ddl = sV-sv[i];
                    ddl/= (2*a[i]);
                    ddl+=d[i];
                }
                cout << ans << " ";
                cout << m-1;
            }
            return 0;
        }
    }
}
